<?php
/**
 * gpa_new Description
 * @package
 * @name User
 * @filesource User.php
 * @author Meta Sanjaya
 */

class User
{
    /**
     * @access public
     * @method __construct
     * @param void
     * @return void
     */
    public function  __construct()
    {
        
    }

    public static function getUserId()
    {
        $session = User::getSession();
        if($session) {
            return $session['user_id'];
        }

        return 0;
    }

    public static function getSession()
    {
        $return = array();

        if($json = @getInstance('cookie')->get('user')) {
            $return = json_decode($json, true);
        }

        return $return;
    }

    public static function setSession($arrayInfo=array())
    {
        getInstance('cookie')->set('user', json_encode($arrayInfo));
    }

    public static function signOut() {
        getInstance('cookie')->remove('user');
    }

    public static function hasAccessControl($app, $act)
    {
        $session = User::getSession();
        if(!isset($session['isAdmin'])) {
            $acl = json_decode($session['acl'], true);
            return false;
        }

        return true;
    }
}
?>